/**
 * @class NG.models.NetworkInfo
 * @extend Ext.data.Model
 * 
 * Used by {@link NG.response.NetworkInfo} request.
 * 
 */
NG.models.NetworkInfo = Ext.regModel("NG.models.NetworkInfo", {
	/**
	 * Fields:<br>
	 * <li>id
	 * <li>network: Object
	 * <li>useableRoadKinds: Array
	 * 
	 * @property fields
	 * @type Array
	 */	
    fields: [
        {name: "id", type: "int", defaultValue: 1},
        {name: "network", defaultValue: {}},
        {name: "useableRoadKinds", defaultValue: []}
   	],
   	
   	/**
   	 * Sets network and adds getNetworkName method to network object.
   	 * @param {NG.models.NetworkInfo} network
   	 */
   	setNetwork: function (network){
   		var result = Ext.apply(network, {
   			getNetworkName:function (){
   				return this.networkName;
   			}   			
   		});
   		this.data.network = result;
   	},

   	/**
   	 * 
   	 * @param {Array} useableRoadKinds
   	 */
   	setUseableRoadKinds: function (useableRoadKinds) {
   		this.data.useableRoadKinds = useableRoadKinds;
   	},

   	/**
   	 * @private
   	 */
   	phantom: true,
   	
   	/**
   	 * 
   	 * @return {String} Id of the model.
   	 */
   	getId: function (){return this.data.id;},
   	
   	/**
   	 * 
   	 * @return {NG.models.NetworkInfo}
   	 */
   	getNetwork: function (){return this.data.network;},
   	
   	/**
   	 * 
   	 * @return {Array} road array
   	 */
   	getUseableRoadKinds: function (){return this.data.useableRoadKinds;},
   	
   	/**
   	 * This method is called when a model is being listed in a List.
   	 * 
   	 * @return {String} Text when network info is being listed in a List view.
   	 */
   	getTableDisplayValue: function (){
   		return this.getNetwork().getNetworkName();
   	}
});
